import numpy as np

# ====== 1. 细分市场吸引力评估模型 ======
class MarketAttractiveness:
    def __init__(self):
        # 评估维度权重（德尔菲法确定）
        self.weights = np.array([0.35, 0.30, 0.20, 0.15])  # [市场规模, 增长率, 竞争强度, 政策支持]
        
        # 细分市场四维评分矩阵（1-10分）
        self.scores = np.array([
            [9.5, 9.8, 4.2, 8.8],  # IKN高净值家庭
            [8.2, 9.0, 6.5, 9.5],  # 网约车司机
            [5.8, 7.2, 3.0, 9.2],  # 政府公务车
            [6.2, 6.5, 5.8, 6.5]   # 苏门答腊企业主
        ])
        
        # 市场名称映射
        self.market_names = {
            0: "IKN高净值家庭",
            1: "网约车司机",
            2: "政府公务车",
            3: "苏门答腊企业主"
        }
    
    def calculate_attractiveness(self):
        """计算各市场综合吸引力得分"""
        weighted_scores = np.dot(self.scores, self.weights)
        return weighted_scores
    
    def select_target_markets(self, threshold=7.5):
        """选择目标市场并输出决策建议"""
        scores = self.calculate_attractiveness()
        ranked_markets = np.argsort(scores)[::-1]  # 按得分降序排序
        
        print("="*50)
        print("印尼新能源汽车细分市场吸引力评估结果")
        print("="*50)
        for idx in ranked_markets:
            print(f"- {self.market_names[idx]}: {scores[idx]:.2f}分")
        
        # 选择超过阈值的目标市场
        target_markets = [self.market_names[idx] for idx in ranked_markets if scores[idx] > threshold]
        
        print("\n" + "="*50)
        print("目标市场选择决策建议")
        print("="*50)
        print(f"核心目标市场: {target_markets[0]}")
        print(f"战略机会市场: {target_markets[1] if len(target_markets)>1 else '无'}")
        

# ====== 2. 执行评估 ======
if __name__ == "__main__":
    evaluator = MarketAttractiveness()
    evaluator.select_target_markets()  # 修正缩进，与if语句块保持一致    